//
//  CALoginBottomView.m
//  LNH
//
//  Created by twentylx on 2018/2/4.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CALoginBottomView.h"

@implementation CALoginBottomView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.tipsLabel];
    [self addSubview:self.loginButton];
    [self addSubview:self.threeLabel];
    [self addSubview:self.wechatButton];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(30);
        make.top.equalTo(self).offset(50);
        make.right.equalTo(self).offset(-30);
    }];
    
    [_loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.tipsLabel);
        make.top.equalTo(self.tipsLabel.mas_bottom).offset(10);
        make.right.equalTo(self.tipsLabel);
        make.height.mas_equalTo(44);
    }];
    
    [_wechatButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self).offset(-70);
    }];
    
    [_threeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self.wechatButton.mas_top).offset(-20);
    }];
}

#pragma mark get & set
- (UILabel *)tipsLabel {
    if (!_tipsLabel) {
        _tipsLabel  = [ UILabel new];
        _tipsLabel.text = @"温馨提示：未注册靓女汇账号的手机号，登录时将自动注册，且代表您已同意（用户服务协议）";
        _tipsLabel.font = [UIFont systemFontOfSize:14];
        _tipsLabel.textColor = RGBCOLOR(128, 128, 128);
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
        _tipsLabel.numberOfLines = 2;
        _tipsLabel.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _tipsLabel;
}

- (UIButton *)loginButton {
    if (!_loginButton) {
        _loginButton = [UIButton new];
        [_loginButton setTitle:@"登录" forState:UIControlStateNormal];
        _loginButton.backgroundColor = RGBCOLOR(255, 61, 0);
        _loginButton.titleLabel.font = [UIFont systemFontOfSize:20];
        _loginButton.layer.cornerRadius = 5;
    }
    return _loginButton;
}

- (UILabel *)threeLabel {
    if (!_threeLabel) {
        _threeLabel = [UILabel new];
        _threeLabel.text = @"第三方登录";
        _threeLabel.font = [UIFont systemFontOfSize:16];
        _threeLabel.textColor = RGBCOLOR(128, 128, 128);
        _threeLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _threeLabel;
}

- (UIButton *)wechatButton {
    if (!_wechatButton) {
        _wechatButton = [UIButton new];
        [_wechatButton setImage:LMImageNamed(@"wechat") forState:UIControlStateNormal];
    }
    return _wechatButton;
}

@end
